package shuishijie.suishijie.model;

import android.text.TextUtils;



import java.io.Serializable;

import shuishijie.suishijie.util.AppUtil;

/**
 * Created by mindx on 2017/8/29.
 */

public class ShoppingCarInfo implements Serializable {

    /**
     * account : 10
     * deleteStatus : false
     * goodsName : 大大大大大大大大
     * goodsid : 1061
     * goodsspecproperty_id : 523_
     * id : 1
     * isCheck : false
     * name : 大小
     * path : http://fcp.oss-cn-beijing.aliyuncs.com/goods/e050ae65-c0c9-4dd7-bc3a-536d80885ef9.png
     * price : 8.0
     * spec_id : 1
     * spec_value : 大大大
     * storageNum : 10
     * tag : 1
     */

    public boolean soldOut() {
        return AppUtil.parseInt(storageNum) <= 0;
    }
    public int account;
    public boolean deleteStatus;
    public String goodsName;
    public int goodsid;
    public String goodsspecproperty_id;
    public int id;
    public boolean isCheck;
    public String name;
    public String path;
    public double price;
    public double marketPrice;
    public String spec_id;
    public String spec_value;
    public String storageNum;
    public String tag;
    /**
     * inventory_type : all
     * marketPrice : 31.0
     * price : 27.0
     */

    public String inventory_type;

    /**
     * inventory_type : all
     * marketPrice : 31.0
     * price : 27.0
     * storageNum : 280
     */


    /**
     * marketPrice : 32
     * price : 18
     * status : 1
     * storageNum : 32
     */

    public String status;

    /**
     * 非接口参数，逻辑添加
     */
    private boolean paySellected = false;
    private boolean delSellected = false;
    public boolean editMode = false;
    public int editCount = 0;

    public boolean isSellected() {
        if (deleteStatus || soldOut()) {
            paySellected = false;
        }
        if (TextUtils.equals(status, "1")) { // 抢购中的，不能购买
            paySellected = false;
        }
        return editMode ? delSellected : paySellected;
    }

    public void setSellected(boolean sellected) {
        if (editMode) {
            delSellected = sellected;
        } else {
            if (deleteStatus || soldOut()) {
                paySellected = false;
            } else {
                paySellected = sellected;
            }
        }
    }


}
